package com.atstudy.headline.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.math.BigDecimal;
import java.util.Date;

import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * 广告计划表
 * @TableName ad_campaigns
 */
@TableName(value ="ad_campaigns", autoResultMap = true)
@Data
public class AdCampaigns {
    /**
     * 广告计划ID
     */
    @TableId(type = IdType.AUTO)
    private Integer campaignId;

    /**
     * 广告主ID
     */
    private Integer advertiserId;

    // 公司名称
    @TableField(exist = false)
    private String companyName;

    /**
     * 计划名称
     */
    private String campaignName;

    /**
     * 开始时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date startTime;

    /**
     * 结束时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date endTime;

    /**
     * 预算
     */
    private BigDecimal budget;

    /**
     * 每日预算
     */
    private BigDecimal dailyBudget;

    /**
     * 出价类型（1:CPC，2:CPM，3:CPA）
     */
    private Integer biddingType;

    /**
     * 出价
     */
    private BigDecimal bidPrice;

    /**
     * 目标受众
     */
//    @TableField(typeHandler = JacksonTypeHandler.class)
    private Object targetAudience;

    /**
     * 状态（1:草稿，2:审核中，3:运行中，4:暂停，5:结束）
     */
    private Integer status;

    /**
     * 创建时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /**
     * 更新时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;
    /**
     * 级联标志
     */
    private int isCascade;

    /**
     * 广告主状态
     */
    @TableField(exist = false)
    private int advertisersStatus;

    /**
     * 存储状态
     */
    private int preCascadeStatus;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        AdCampaigns other = (AdCampaigns) that;
        return (this.getCampaignId() == null ? other.getCampaignId() == null : this.getCampaignId().equals(other.getCampaignId()))
            && (this.getAdvertiserId() == null ? other.getAdvertiserId() == null : this.getAdvertiserId().equals(other.getAdvertiserId()))
            && (this.getCampaignName() == null ? other.getCampaignName() == null : this.getCampaignName().equals(other.getCampaignName()))
            && (this.getStartTime() == null ? other.getStartTime() == null : this.getStartTime().equals(other.getStartTime()))
            && (this.getEndTime() == null ? other.getEndTime() == null : this.getEndTime().equals(other.getEndTime()))
            && (this.getBudget() == null ? other.getBudget() == null : this.getBudget().equals(other.getBudget()))
            && (this.getDailyBudget() == null ? other.getDailyBudget() == null : this.getDailyBudget().equals(other.getDailyBudget()))
            && (this.getBiddingType() == null ? other.getBiddingType() == null : this.getBiddingType().equals(other.getBiddingType()))
            && (this.getBidPrice() == null ? other.getBidPrice() == null : this.getBidPrice().equals(other.getBidPrice()))
            && (this.getTargetAudience() == null ? other.getTargetAudience() == null : this.getTargetAudience().equals(other.getTargetAudience()))
            && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
            && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getCampaignId() == null) ? 0 : getCampaignId().hashCode());
        result = prime * result + ((getAdvertiserId() == null) ? 0 : getAdvertiserId().hashCode());
        result = prime * result + ((getCampaignName() == null) ? 0 : getCampaignName().hashCode());
        result = prime * result + ((getStartTime() == null) ? 0 : getStartTime().hashCode());
        result = prime * result + ((getEndTime() == null) ? 0 : getEndTime().hashCode());
        result = prime * result + ((getBudget() == null) ? 0 : getBudget().hashCode());
        result = prime * result + ((getDailyBudget() == null) ? 0 : getDailyBudget().hashCode());
        result = prime * result + ((getBiddingType() == null) ? 0 : getBiddingType().hashCode());
        result = prime * result + ((getBidPrice() == null) ? 0 : getBidPrice().hashCode());
        result = prime * result + ((getTargetAudience() == null) ? 0 : getTargetAudience().hashCode());
        result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", campaignId=").append(campaignId);
        sb.append(", advertiserId=").append(advertiserId);
        sb.append(", campaignName=").append(campaignName);
        sb.append(", startTime=").append(startTime);
        sb.append(", endTime=").append(endTime);
        sb.append(", budget=").append(budget);
        sb.append(", dailyBudget=").append(dailyBudget);
        sb.append(", biddingType=").append(biddingType);
        sb.append(", bidPrice=").append(bidPrice);
        sb.append(", targetAudience=").append(targetAudience);
        sb.append(", status=").append(status);
        sb.append(", createTime=").append(createTime);
        sb.append(", updateTime=").append(updateTime);
        sb.append("]");
        return sb.toString();
    }
}
